﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace RpcGenerator
{
    class FileGeneratorEx
    {
        public static void GenerateAS3(string file, string content)
        {
            int index = file.LastIndexOf('/');
            string dir = file.Substring(0, index);
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }            
            FileStream fs = File.Open(file, FileMode.Create);
            byte[] bytes = Encoding.ASCII.GetBytes(content);
            fs.Write(bytes, 0, bytes.Length);
            fs.Flush();
            fs.Close();
        }

        public static void GenerateLua(string file, string content)
        {
			int index = file.LastIndexOf('/');
            string dir = file.Substring(0, index);
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            FileStream fs = File.Open(file, FileMode.Create);
            byte[] bytes = Encoding.ASCII.GetBytes(content);
            fs.Write(bytes, 0, bytes.Length);
            fs.Flush();
            fs.Close();
        }
    }
}
